#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int a = 0;
	int b = 0;
	int num = 0;
	scanf("%d%d", &a, &b);
	int c = a > b ? b : a;
	for (int u = 2; i <= b; i++)
	{
		if (a % i == 0 && b % i == 0)
			num = i;
	}
	printf("%d", num);
	return 0;
}